import Vue from 'vue'
import App from './App.vue'
import router from './router'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import axios from 'axios'

axios.defaults.baseURL = 'http://localhost:8888'

axios.interceptors.request.use(
    config => {
      const username = localStorage.getItem('username')
      if (username) {
        config.headers['X-Username'] = username
      }
      return config
    },
    error => {
      return Promise.reject(error)
    }
)

Vue.config.productionTip = false
Vue.use(ElementUI)
Vue.prototype.$axios = axios

new Vue({
  router,
  render: h => h(App),
}).$mount('#app')
